package com.chaucer.dynamicdemo.controller;

import com.chaucer.dynamicdemo.entity.HelloWorldEntity;
import com.chaucer.dynamicdemo.service.HelloWorldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * @Description TODO
 * @Author Chaucer
 * @Date 2021/9/3 22:55
 */
@RestController
public class HelloWorldController {
    @Autowired
    HelloWorldService service;
    @RequestMapping(value = "/save", method = POST)
    public String insert(@RequestBody HelloWorldEntity entity) {

        /**
         * 插入数据
         */

        try {
            service.save(entity);
        } catch (Exception e) {
            return "failed";
        }
        try {
            service.saveByDynamic(entity);
        } catch (Exception e) {
            return "failed";
        }
        return "success";
    }
    @RequestMapping
    public void find(){

    }
}